%% Produce Figure 1 based on real-time break test results


%% Colour Scheme


% Coloured Figures

% red = [1 0 0];
% darkblue = [0 0 0.5];

% Black and White Figures

darkblue = [0.2 0.2 0.2];
red = [0 0 0];

%% Figure

load('output\results_Figure1')

f = figure(1);
[hAx,hLine1,hLine2] = plotyy(testResults(:,1),[ testResults(:,3) testResults(:,4) testResults(:,2)],...
    testResults(:,1),[ testResults(:,5) nan*testResults(:,6) nan*testResults(:,7)]);

% Note that Matlab 2015 or later is required for the two axis option here

hLine1(3).Color = darkblue;
hLine1(3).LineWidth = 3;
hLine1(1).Color = red;
hLine1(1).LineWidth = 2;
hLine1(1).LineStyle = '--';
hLine1(2).LineWidth = 2;
hLine1(2).LineStyle = ':';
hLine1(2).Color = red;

hLine2(1).Color = [0.6 0.6 0.6];
hLine2(1).LineWidth = 2;

ylabel(hAx(1),'Bai and Perron') % left y-axis
ylabel(hAx(2),'Nyblom') % right y-axis

ymin2 = -0.11;
ymax2 = 0.503;
ylim(hAx(2),[ymin2, ymax2])


datesToPlot = datenum(2000:2:2015,1,31);
YAxisTicks = [0:1:9];
YAxisTicks2 = [ymin2:(ymax2-ymin2)/8:ymax2];

set(hAx(1),'XTick',datesToPlot,'GridLineStyle',':','YTick',YAxisTicks)
set(hAx(2),'XTick',datesToPlot,'GridLineStyle',':','YTick',YAxisTicks2)
labels2 = num2str(round(100*str2double(get(hAx(2),'yticklabel')))/100);

set(hAx(2),'yticklabel',labels2)

datetick('x','yyyy','keepticks')
xmin=datenum(2000,1,31);
xmax=datenum(2015,7,31);
xlim(hAx(1),[xmin,xmax])
xlim(hAx(2),[xmin,xmax])

ymin = 1;
ymax = 9;
ylim(hAx(1),[ymin,ymax])

grid on

figSize = [7 5];
set(f, 'PaperUnits', 'inches');
set(f, 'Units','inches');
set(f, 'PaperSize', figSize);
set(f, 'PaperPositionMode', 'auto');
set(f, 'Position', [0 0 figSize(1) figSize(2)])
set(hAx(1), 'FontName', 'Times-Roman');
set(hAx(1), 'FontSize', 14);
set(hAx(1), 'Layer','top');
set(hAx(2), 'FontName', 'Times-Roman');
set(hAx(2), 'FontSize', 14);
set(hAx(2), 'Layer','top');
% set(gca,'OuterPosition',[-0.12 -.06 1.2 1.1]);

ti = get(gca,'TightInset');
set(gca,'Position',[1*ti(1) 1.1*ti(2) 0.90*(1-ti(3)-ti(1)) 0.99*(1-ti(4)-ti(2))]);


fname = strcat('output\Figure1.pdf');
print('-dpdf', f, fname);
    
